package main

// 调试器不好安装
import "fmt"

var a [5]int

func main() {
	a[0] = 10

	for i := 0; i < len(a); i++ {
		if a[i] == 0 {
			a[i] = a[i-1] + i
		}

	}
	fmt.Println(a)
	var f = Adder()
	fmt.Println(f(1))
	fmt.Println(f(20))
	fmt.Println(f(300))
	var d = Adder()
	fmt.Println(d(1))
	fmt.Println(d(20))
	fmt.Println(d(200))
}

func Adder() func(int) int {
	var x int
	return func(delta int) int {
		x += delta
		return x
	}
}
